package entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@Entity
public class BranchEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String branchName;
    private String contactNumber;
    private String contactPerson;
    
    //team 32 attributes
     private int billingDay;
    
    @ManyToOne private StakeholderEntity stakeholder;
    
    @OneToOne
    private FnBBranchEntity fnBBranch;
    
    @OneToOne
    private AddressEntity branchAddress;
    
    @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "branch")
    private Set<BranchOperatingHoursEntity> operatingHours = new HashSet<BranchOperatingHoursEntity>();
    
    public BranchEntity(){
        
        
    }
    public BranchEntity(String branchName, String contactNumber, String contactPerson){
        this.contactNumber= contactNumber;
        this.branchName = branchName;
        this.contactPerson = contactPerson;
    
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BranchEntity)) {
            return false;
        }
        BranchEntity other = (BranchEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Branch[ id=" + id + " ]";
    }

    public String getContactNumber() {
        return contactNumber;
    }

    public void setContactNumber(String contactNumber) {
        this.contactNumber = contactNumber;
    }
    
    public String getContactPerson() {
        return contactPerson;
    }

    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson;
    }

    public Long getBranchId() {
        return id;
    }

    public void setBranchId(Long branchId) {
        this.id = branchId;
    }

    public String getBranchName() {
        return branchName;
    }

    public void setBranchName(String branchName) {
        this.branchName = branchName;
    }

    public Set<BranchOperatingHoursEntity> getOperatingHours() {
        return operatingHours;
    }

    public void setOperatingHours(Set<BranchOperatingHoursEntity> operatingHours) {
        this.setOperatingHours(operatingHours);
    }

    public FnBBranchEntity getFnBBranch() {
        return fnBBranch;
    }

    public void setFnBBranch(FnBBranchEntity fnBBranch) {
        this.fnBBranch = fnBBranch;
    }

    public AddressEntity getBranchAddress() {
        return branchAddress;
    }

    public void setBranchAddress(AddressEntity branchAddress) {
        this.branchAddress = branchAddress;
    }

    /**
     * @return the billingDay
     */
    public int getBillingDay() {
        return billingDay;
    }

    /**
     * @return the stakeholder
     */
    public StakeholderEntity getStakeholder() {
        return stakeholder;
    }

    /**
     * @param billingDay the billingDay to set
     */
    public void setBillingDay(int billingDay) {
        this.billingDay = billingDay;
    }

    /**
     * @param stakeholder the stakeholder to set
     */
    public void setStakeholder(StakeholderEntity stakeholder) {
        this.stakeholder = stakeholder;
    }
}
